package com.zrrd.axiosDemo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author WanJl
 * @version 1.0
 * @title AxiosDemoServlet01
 * @description
 * @create 2024/1/20 14:17
 */
@WebServlet("/axiosDemoServlet01")  //url一般采用都是小驼峰
public class AxiosDemoServlet01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String age = req.getParameter("age");
        String gender = req.getParameter("gender");
        System.out.println("GET....");
        System.out.println(name);
        System.out.println(age);
        System.out.println(gender);
        //响应给发起请求的前端页面
        resp.getWriter().write("GET....");
        resp.getWriter().write(name);
        resp.getWriter().write(age);
        resp.getWriter().write(gender);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String age = req.getParameter("age");
        String gender = req.getParameter("gender");

        System.out.println("POST....");
        System.out.println(name);
        System.out.println(age);
        System.out.println(gender);
        //响应给发起请求的前端页面
        resp.getWriter().write("POST....");
        resp.getWriter().write(name);
        resp.getWriter().write(age);
        resp.getWriter().write(gender);
    }
}
